package cn.edu.gzhu.workOrderManagement.enumeration;

import lombok.Getter;

import java.util.Objects;


public enum UserAuthorityEnum {

    ADMIN(1,"管理员"),


    HEAD_LEADER(2,"总部负责人"),

    HEAD_BUSINESS(2,"总部商务"),

    HEAD_AUDITORS(2,"总部稽查"),


    BRANCH_LEADER(3,"分支机构负责人"),

    BRANCH_SUPERVISOR(3,"分支机构主管"),

    BRANCH_BUSINESS(2,"分支机构商务"),

    BRANCH_WORK_HANDLER(4,"分支机构工单处理员"),

    BRANCH_AUDITORS(2,"分支机构稽查"),

    BRANCH_MATERIAL_HANDLER(4,"分支机构材料处理员"),

    CLIENT(5,"客户");

    @Getter
    private final Integer authority;

    @Getter
    private final String role;

    UserAuthorityEnum(Integer authority,String role) {
        this.authority = authority;
        this.role = role;
    }

    public static UserAuthorityEnum value2Object(String role) {
        for (UserAuthorityEnum e : UserAuthorityEnum.values()) {
            if (Objects.equals(e.role, role)) {
                return e;
            }
        }
        throw new IllegalArgumentException("不合法的角色:" + role + "。");
    }


}
